import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = new int[arr.length];

        System.arraycopy(arr, 1, str, 0, arr.length - 1);

        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(str));

    }
    public static void main8(String[] args) {
        int[] arr = {1, 2, 3, 4};
        int[] str = Arrays.copyOf(arr, arr.length * 2);
        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(str));
    }
    public static void main7(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        int[] copyarr = new int[arr.length];
        for(int i = 0; i < arr.length; i++) {
            copyarr[i] = arr[i];
        }
        System.out.println(Arrays.toString(arr));
        System.out.println(Arrays.toString(copyarr));
    }
    public static String mytoString(int[] arr) {
        if(arr == null) {
            return null;
        }
        String ret = "[";
        for(int i = 0; i < arr.length; i++) {
            ret += arr[i];
            if(i < arr.length - 1) {
                ret = ret + ',' +' ';
            }
        }
        ret += ']';
        return ret;
    }
    public static void main6(String[] args) {
        int[] arr = null;
        String ret = mytoString(arr);
        System.out.println(ret);
    }
    public static void myToString(int[] arr) {
        System.out.print('[');
        for(int x : arr) {
            if(x != arr[arr.length - 1]) {
                System.out.print(x + "," + " ");
            }else {
                System.out.print(x);
            }

        }
        System.out.print(']');

    }
    public static void main5(String[] args) {
        int[] arr = {1, 2 ,3 ,4, 5};
        myToString(arr);
//        String ret = myToString(arr);
//        System.out.println(ret);
    }
    public static void main4(String[] args) {
        int[] arr;
        arr = new int[]{1, 2, 3};
        int[] arr1 = new int[]{2,3};
        arr1 = new int[]{1, 2};
        arr1 = new int[]{3, 4};
    }
    public static int[] fun() {
        int[] tmp = {1, 2, 3, 4};
        return tmp;
    }
    public static void main3(String[] args) {
        int[] ret = fun();
        System.out.println(Arrays.toString(ret));
    }
    public static void func1(int[] arr) {
        arr = new int[10];
    }
    public static void func2(int[] arr) {
        arr[0] = 99;
    }
    public static void main2(String[] args) {
        int[] arr = {1, 2, 3 ,4};
        func2(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main1(String[] args) {
        int[] arr = {1, 2, 3};
        System.out.println(arr);
    }
}
